package common;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author lileilei
 * @Description
 * @create 2020-06-20 17:35
 */
public class StringToList {
    public List<Map<String,Object>> strtolist(String string){
        List<Map<String,Object>> resliut=new ArrayList<>();
        if(!"[]".equals(string)){
            String[] syrimng=string.split("\\[")[1].split("]")[0].split("},\\{");
            for (int i=0;i<syrimng.length;i++){
                Map<String,Object> newo=new HashMap<>();
                if(i==0){
                    String one=syrimng[0].substring(1);
                    for (String newone:one.split(",")){
                        if (!" intefaceDetailParamesVoList".equals(newone.split("=")[0])){
                            newo.put(newone.split("=")[0],newone.split("=")[1]);
                        }
                        else {
                            String parmeone=string.split(" intefaceDetailParamesVoList")[1].split("\\[")[1].split("]")[0].split("\\{")[1].split("\\}")[0];
                            Map<String,Object> oa=new HashMap<>();
                            String[] strings=parmeone.split(",");
                            for (String s:strings){
                                oa.put(s.split("=")[0],s.split("=")[1]);
                            }
                            newo.put("parames",oa);
                        }
                    }
                }else if (i==syrimng.length){
                    String one=syrimng[-1].substring(0,-1);
                    for (String newone:one.split(",")){
                        newo.put(newone.split("=")[0],newone.split("=")[1]);
                    }
                }else {
                    String one=syrimng[i];
                    for (String newone:one.split(",")){

                        newo.put(newone.split("=")[0],newone.split("=")[1]);
                    }
                }

                resliut.add(newo);
            }
        }
        return resliut;
    }
}
